/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * MainFrame.java
 *
 * Created on Aug 29, 2011, 2:12:08 PM
 */
package isvp.ui;

import isvp.constants.ISVPConstants;
import isvp.constants.UIConstants;
import isvp.events.ISVPTreeSelectionEvent;
import isvp.exceptions.ISVPException;
import isvp.implementations.ISVPFactory;
import isvp.interfaces.Application;
import isvp.interfaces.ISVP;
import isvp.interfaces.ISVPFrame;
import isvp.interfaces.Privilege;
import isvp.ui.beans.ISVPJPanel;
import isvp.utilities.XMLUtils;
import java.awt.CardLayout;
import java.awt.Color;
import java.awt.Container;
import java.awt.LayoutManager;
import java.io.File;
import java.util.TreeMap;
import javax.swing.JFileChooser;
import javax.swing.JOptionPane;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;
import org.w3c.dom.Node;
import org.xml.sax.SAXException;

/**
 *
 * @author jjophin
 */
public class MainFrame extends javax.swing.JFrame implements ISVPFrame {
    private ISVP isvpObject = null;
    private static String selectedFilePath;
    
    /** Creates new form MainFrame */
    public MainFrame() {
        try {
            UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
        } catch (ClassNotFoundException ex) {
        } catch (InstantiationException ex) {
        } catch (IllegalAccessException ex) {
        } catch (UnsupportedLookAndFeelException ex) {
        }
        initComponents();
        initEvents();
        showMainPanes(false);
        getContentPane().setBackground(new Color(236, 233, 216));
        setVisible(true);        
    }
    
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        isvpChooser = new javax.swing.JFileChooser();
        treePane = new javax.swing.JScrollPane();
        componentTree = new isvp.ui.beans.ISVPTree();
        positioningPanel = new javax.swing.JPanel();
        containerPane = new javax.swing.JPanel();
        myPrivilegesPanel = new isvp.ui.beans.ISVPJPanel();
        fieldsPanel = new javax.swing.JPanel();
        priFileNameLabel = new javax.swing.JLabel();
        priFileNameField = new javax.swing.JTextField();
        priNameLabel = new javax.swing.JLabel();
        priNameField = new javax.swing.JTextField();
        priIdLabel = new javax.swing.JLabel();
        priIdField = new javax.swing.JTextField();
        priDescriptionLabel = new javax.swing.JLabel();
        priDescriptionField = new javax.swing.JTextField();
        priMenuKeyLabel = new javax.swing.JLabel();
        priMenuKeyField = new javax.swing.JTextField();
        priCordysRoleDnLabel = new javax.swing.JLabel();
        priCordysRoleDnField = new javax.swing.JTextField();
        priTabContainer = new javax.swing.JTabbedPane();
        jScrollPane3 = new javax.swing.JScrollPane();
        priPsvField = new javax.swing.JTextArea();
        jScrollPane4 = new javax.swing.JScrollPane();
        priMenuXmlField = new javax.swing.JTextArea();
        jScrollPane5 = new javax.swing.JScrollPane();
        priFormsField = new javax.swing.JTextArea();
        jScrollPane6 = new javax.swing.JScrollPane();
        priBoAccessField = new javax.swing.JTextArea();
        jScrollPane7 = new javax.swing.JScrollPane();
        priReadFilterField = new javax.swing.JTextArea();
        jScrollPane8 = new javax.swing.JScrollPane();
        priInsertFilterField = new javax.swing.JTextArea();
        jScrollPane9 = new javax.swing.JScrollPane();
        priUpdateFilterField = new javax.swing.JTextArea();
        jScrollPane10 = new javax.swing.JScrollPane();
        priDeleteFilterField = new javax.swing.JTextArea();
        jScrollPane11 = new javax.swing.JScrollPane();
        priAttachFilterField = new javax.swing.JTextArea();
        jScrollPane12 = new javax.swing.JScrollPane();
        priMobileField = new javax.swing.JTextArea();
        jScrollPane2 = new javax.swing.JScrollPane();
        priLabelField = new javax.swing.JTextArea();
        myApplicationDetailsPanel = new isvp.ui.beans.ISVPJPanel();
        fileNameLabel = new javax.swing.JLabel();
        appFileNameField = new javax.swing.JTextField();
        appNameLabel = new javax.swing.JLabel();
        appNameField = new javax.swing.JTextField();
        appIdLabel = new javax.swing.JLabel();
        appIdField = new javax.swing.JTextField();
        appDescriptionLabel = new javax.swing.JLabel();
        appDescriptionField = new javax.swing.JTextField();
        tenantIdLabel = new javax.swing.JLabel();
        tenantIdField = new javax.swing.JTextField();
        langCodeLabel = new javax.swing.JLabel();
        languageCodeField = new javax.swing.JTextField();
        createdDateLabel = new javax.swing.JLabel();
        createdDateField = new javax.swing.JTextField();
        myLanguagesPanel = new isvp.ui.beans.ISVPJPanel();
        languageNameLabel = new javax.swing.JLabel();
        languageNameField = new javax.swing.JTextField();
        langugaeCodeLabel = new javax.swing.JLabel();
        langugaeCodeField = new javax.swing.JTextField();
        languageCreatedByLabel = new javax.swing.JLabel();
        languageCreatedByField = new javax.swing.JTextField();
        languageCreatedDateLabel = new javax.swing.JLabel();
        languageCreatedDateField = new javax.swing.JTextField();
        languageModifiedByLabel = new javax.swing.JLabel();
        languageModifiedByField = new javax.swing.JTextField();
        languageModifiedDateLabel = new javax.swing.JLabel();
        languageModifiedDateField = new javax.swing.JTextField();
        myIsvpDetailsPanel = new isvp.ui.beans.ISVPJPanel();
        isvPathLabel = new javax.swing.JLabel();
        isvNameLabel = new javax.swing.JLabel();
        isvUpdateNumLabel = new javax.swing.JLabel();
        isvPathField = new javax.swing.JTextField();
        isvNameField = new javax.swing.JTextField();
        isvUpdateNumField = new javax.swing.JTextField();
        isvTab = new javax.swing.JTabbedPane();
        jScrollPane13 = new javax.swing.JScrollPane();
        isvOrgMail = new javax.swing.JTextArea();
        jPanel1 = new javax.swing.JPanel();
        jLabel3 = new javax.swing.JLabel();
        BPNameField = new javax.swing.JTextField();
        jLabel4 = new javax.swing.JLabel();
        clusterNameField = new javax.swing.JTextField();
        getAppRequest = new javax.swing.JButton();
        jSeparator2 = new javax.swing.JSeparator();
        jScrollPane1 = new javax.swing.JScrollPane();
        requestTextArea = new javax.swing.JTextArea();
        jSeparator1 = new javax.swing.JSeparator();
        jLabel1 = new javax.swing.JLabel();
        jMenuBar1 = new javax.swing.JMenuBar();
        jMenu1 = new javax.swing.JMenu();
        fileOpen = new javax.swing.JMenuItem();

        isvpChooser.setAcceptAllFileFilterUsed(false);
        isvpChooser.setBackground(new java.awt.Color(236, 233, 216));
        isvpChooser.setFileFilter(new isvp.utilities.ExtensionFileFilter());

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("CPF ISVP Explorer");
        setForeground(new java.awt.Color(236, 233, 216));
        setName("MainISVPFrame"); // NOI18N

        componentTree.setBackground(new java.awt.Color(236, 233, 216));
        treePane.setViewportView(componentTree);

        myPrivilegesPanel.setVisible(false);

        fieldsPanel.setMaximumSize(new java.awt.Dimension(484, 161));
        fieldsPanel.setMinimumSize(new java.awt.Dimension(484, 161));

        priFileNameLabel.setText("File Name");

        priFileNameField.setText(" ");
        priFileNameField.setToolTipText("The name of the xml file in which the application details were present in the ISVP.");

        priNameLabel.setText("Privilege Name");

        priNameField.setText(" ");

        priIdLabel.setText("Privilege ID");

        priIdField.setText(" ");

        priDescriptionLabel.setText("Description");

        priDescriptionField.setText(" ");

        priMenuKeyLabel.setText("Menu Key");

        priMenuKeyField.setText(" ");

        priCordysRoleDnLabel.setText("Cordys Role DN");

        priCordysRoleDnField.setText(" ");

        javax.swing.GroupLayout fieldsPanelLayout = new javax.swing.GroupLayout(fieldsPanel);
        fieldsPanel.setLayout(fieldsPanelLayout);
        fieldsPanelLayout.setHorizontalGroup(
            fieldsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(fieldsPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(fieldsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                    .addComponent(priDescriptionLabel, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(priCordysRoleDnLabel, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(priIdLabel, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(priFileNameLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(priNameLabel, javax.swing.GroupLayout.DEFAULT_SIZE, 79, Short.MAX_VALUE)
                    .addComponent(priMenuKeyLabel, javax.swing.GroupLayout.Alignment.LEADING))
                .addGap(30, 30, 30)
                .addGroup(fieldsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(priFileNameField, javax.swing.GroupLayout.PREFERRED_SIZE, 361, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(priNameField, javax.swing.GroupLayout.PREFERRED_SIZE, 361, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(priIdField, javax.swing.GroupLayout.PREFERRED_SIZE, 361, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(priDescriptionField, javax.swing.GroupLayout.PREFERRED_SIZE, 361, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(priCordysRoleDnField, javax.swing.GroupLayout.PREFERRED_SIZE, 361, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(priMenuKeyField, javax.swing.GroupLayout.PREFERRED_SIZE, 361, javax.swing.GroupLayout.PREFERRED_SIZE)))
        );
        fieldsPanelLayout.setVerticalGroup(
            fieldsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, fieldsPanelLayout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(fieldsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(priFileNameLabel)
                    .addComponent(priFileNameField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(fieldsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(priNameLabel)
                    .addComponent(priNameField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(fieldsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(priIdLabel)
                    .addComponent(priIdField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(fieldsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(priDescriptionLabel)
                    .addComponent(priDescriptionField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(fieldsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(priCordysRoleDnLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 14, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(priCordysRoleDnField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(fieldsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(priMenuKeyLabel)
                    .addComponent(priMenuKeyField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap())
        );

        priTabContainer.setMaximumSize(new java.awt.Dimension(165, 195));

        priPsvField.setColumns(20);
        priPsvField.setRows(5);
        jScrollPane3.setViewportView(priPsvField);

        priTabContainer.addTab("Process Status Viewer Privilege", jScrollPane3);

        priMenuXmlField.setColumns(20);
        priMenuXmlField.setRows(5);
        jScrollPane4.setViewportView(priMenuXmlField);

        priTabContainer.addTab("Menu XML", jScrollPane4);

        priFormsField.setColumns(20);
        priFormsField.setRows(5);
        jScrollPane5.setViewportView(priFormsField);

        priTabContainer.addTab("Form Privileges", jScrollPane5);

        priBoAccessField.setColumns(20);
        priBoAccessField.setRows(5);
        jScrollPane6.setViewportView(priBoAccessField);

        priTabContainer.addTab("BO Access Rights", jScrollPane6);

        priReadFilterField.setColumns(20);
        priReadFilterField.setRows(5);
        jScrollPane7.setViewportView(priReadFilterField);

        priTabContainer.addTab("Read Filter XML", jScrollPane7);

        priInsertFilterField.setColumns(20);
        priInsertFilterField.setRows(5);
        jScrollPane8.setViewportView(priInsertFilterField);

        priTabContainer.addTab("Insert Filter XML", jScrollPane8);

        priUpdateFilterField.setColumns(20);
        priUpdateFilterField.setRows(5);
        jScrollPane9.setViewportView(priUpdateFilterField);

        priTabContainer.addTab("Update Filter XML", jScrollPane9);

        priDeleteFilterField.setColumns(20);
        priDeleteFilterField.setRows(5);
        jScrollPane10.setViewportView(priDeleteFilterField);

        priTabContainer.addTab("Delete Filter XML", jScrollPane10);

        priAttachFilterField.setColumns(20);
        priAttachFilterField.setRows(5);
        jScrollPane11.setViewportView(priAttachFilterField);

        priTabContainer.addTab("Attachment Filter Privileges", jScrollPane11);

        priMobileField.setColumns(20);
        priMobileField.setRows(5);
        jScrollPane12.setViewportView(priMobileField);

        priTabContainer.addTab("Mobile Form Privileges", jScrollPane12);

        priLabelField.setColumns(20);
        priLabelField.setRows(5);
        jScrollPane2.setViewportView(priLabelField);

        priTabContainer.addTab("Label Privileges", jScrollPane2);

        javax.swing.GroupLayout myPrivilegesPanelLayout = new javax.swing.GroupLayout(myPrivilegesPanel);
        myPrivilegesPanel.setLayout(myPrivilegesPanelLayout);
        myPrivilegesPanelLayout.setHorizontalGroup(
            myPrivilegesPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, myPrivilegesPanelLayout.createSequentialGroup()
                .addGroup(myPrivilegesPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(fieldsPanel, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addGroup(myPrivilegesPanelLayout.createSequentialGroup()
                        .addGap(10, 10, 10)
                        .addComponent(priTabContainer, javax.swing.GroupLayout.DEFAULT_SIZE, 470, Short.MAX_VALUE)))
                .addContainerGap())
        );
        myPrivilegesPanelLayout.setVerticalGroup(
            myPrivilegesPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(myPrivilegesPanelLayout.createSequentialGroup()
                .addComponent(fieldsPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(priTabContainer, javax.swing.GroupLayout.PREFERRED_SIZE, 296, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );

        myApplicationDetailsPanel.setVisible(false);

        fileNameLabel.setText("File name");

        appFileNameField.setText(" ");
        appFileNameField.setToolTipText("The name of the xml file in which the application details were present in the ISVP.");

        appNameLabel.setText("Application name");

        appNameField.setText(" ");

        appIdLabel.setText("Application ID    ");

        appIdField.setText(" ");

        appDescriptionLabel.setText("Description");

        appDescriptionField.setText(" ");

        tenantIdLabel.setText("Tenant ID");

        tenantIdField.setText(" ");
        tenantIdField.setToolTipText("The tenant in which the isvp was packed.");

        langCodeLabel.setText("Language code");

        languageCodeField.setText(" ");

        createdDateLabel.setText("Created date");

        createdDateField.setText(" ");

        javax.swing.GroupLayout myApplicationDetailsPanelLayout = new javax.swing.GroupLayout(myApplicationDetailsPanel);
        myApplicationDetailsPanel.setLayout(myApplicationDetailsPanelLayout);
        myApplicationDetailsPanelLayout.setHorizontalGroup(
            myApplicationDetailsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(myApplicationDetailsPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(myApplicationDetailsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(createdDateLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(langCodeLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(tenantIdLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(appDescriptionLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(appIdLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(appNameLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(fileNameLabel, javax.swing.GroupLayout.DEFAULT_SIZE, 98, Short.MAX_VALUE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(myApplicationDetailsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(appFileNameField, javax.swing.GroupLayout.DEFAULT_SIZE, 362, Short.MAX_VALUE)
                    .addComponent(appNameField, javax.swing.GroupLayout.DEFAULT_SIZE, 362, Short.MAX_VALUE)
                    .addComponent(appIdField, javax.swing.GroupLayout.DEFAULT_SIZE, 362, Short.MAX_VALUE)
                    .addComponent(createdDateField, javax.swing.GroupLayout.DEFAULT_SIZE, 362, Short.MAX_VALUE)
                    .addComponent(languageCodeField, javax.swing.GroupLayout.DEFAULT_SIZE, 362, Short.MAX_VALUE)
                    .addComponent(tenantIdField, javax.swing.GroupLayout.DEFAULT_SIZE, 362, Short.MAX_VALUE)
                    .addComponent(appDescriptionField, javax.swing.GroupLayout.DEFAULT_SIZE, 362, Short.MAX_VALUE))
                .addContainerGap())
        );
        myApplicationDetailsPanelLayout.setVerticalGroup(
            myApplicationDetailsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(myApplicationDetailsPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(myApplicationDetailsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(fileNameLabel)
                    .addComponent(appFileNameField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(myApplicationDetailsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(appNameLabel)
                    .addComponent(appNameField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(myApplicationDetailsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(appIdField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(appIdLabel))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(myApplicationDetailsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(appDescriptionLabel)
                    .addComponent(appDescriptionField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(myApplicationDetailsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(tenantIdLabel)
                    .addComponent(tenantIdField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(myApplicationDetailsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(languageCodeField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(langCodeLabel))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(myApplicationDetailsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(createdDateField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(createdDateLabel))
                .addContainerGap(303, Short.MAX_VALUE))
        );

        myLanguagesPanel.setVisible(false);
        myLanguagesPanel.setMinimumSize(new java.awt.Dimension(100, 490));
        myLanguagesPanel.setPreferredSize(new java.awt.Dimension(490, 490));

        languageNameLabel.setText("Language name");

        languageNameField.setText(" ");
        languageNameField.setToolTipText("The name of the xml file in which the application details were present in the ISVP.");

        langugaeCodeLabel.setText("Language code");

        langugaeCodeField.setText(" ");

        languageCreatedByLabel.setText("Created by");

        languageCreatedByField.setText(" ");

        languageCreatedDateLabel.setText("Created date");

        languageCreatedDateField.setText(" ");

        languageModifiedByLabel.setText("Modified by");

        languageModifiedByField.setText(" ");
        languageModifiedByField.setToolTipText("The tenant in which the isvp was packed.");

        languageModifiedDateLabel.setText("Modified date");

        languageModifiedDateField.setText(" ");

        javax.swing.GroupLayout myLanguagesPanelLayout = new javax.swing.GroupLayout(myLanguagesPanel);
        myLanguagesPanel.setLayout(myLanguagesPanelLayout);
        myLanguagesPanelLayout.setHorizontalGroup(
            myLanguagesPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, myLanguagesPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(myLanguagesPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(myLanguagesPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                        .addComponent(languageModifiedByLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(languageCreatedDateLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(languageCreatedByLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(langugaeCodeLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(languageNameLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 98, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(languageModifiedDateLabel, javax.swing.GroupLayout.DEFAULT_SIZE, 108, Short.MAX_VALUE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(myLanguagesPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(languageNameField, javax.swing.GroupLayout.DEFAULT_SIZE, 372, Short.MAX_VALUE)
                    .addComponent(langugaeCodeField, javax.swing.GroupLayout.DEFAULT_SIZE, 372, Short.MAX_VALUE)
                    .addComponent(languageCreatedByField, javax.swing.GroupLayout.DEFAULT_SIZE, 372, Short.MAX_VALUE)
                    .addComponent(languageModifiedDateField, javax.swing.GroupLayout.DEFAULT_SIZE, 372, Short.MAX_VALUE)
                    .addComponent(languageModifiedByField, javax.swing.GroupLayout.DEFAULT_SIZE, 372, Short.MAX_VALUE)
                    .addComponent(languageCreatedDateField, javax.swing.GroupLayout.DEFAULT_SIZE, 372, Short.MAX_VALUE))
                .addContainerGap())
        );
        myLanguagesPanelLayout.setVerticalGroup(
            myLanguagesPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(myLanguagesPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(myLanguagesPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(languageNameLabel)
                    .addComponent(languageNameField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(myLanguagesPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(langugaeCodeLabel)
                    .addComponent(langugaeCodeField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(myLanguagesPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(languageCreatedByField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(languageCreatedByLabel))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(myLanguagesPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(languageCreatedDateLabel)
                    .addComponent(languageCreatedDateField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(myLanguagesPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(languageModifiedByLabel)
                    .addComponent(languageModifiedByField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(myLanguagesPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(languageModifiedDateField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(languageModifiedDateLabel))
                .addContainerGap(360, Short.MAX_VALUE))
        );

        isvPathLabel.setText("ISVP Location");

        isvNameLabel.setText("ISVP Name      ");

        isvUpdateNumLabel.setText("Update Number");

        isvPathField.setText(" ");

        isvNameField.setText(" ");

        isvOrgMail.setColumns(20);
        isvOrgMail.setRows(5);
        jScrollPane13.setViewportView(isvOrgMail);

        isvTab.addTab("Mail Format", jScrollPane13);

        jLabel3.setText("Business Partner Name");

        BPNameField.setText("Cordys");

        jLabel4.setText("Cluster Name");

        clusterNameField.setText("Admin Cluster");

        getAppRequest.setText("Get Request");
        getAppRequest.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                getAppRequestActionPerformed(evt);
            }
        });

        requestTextArea.setColumns(20);
        requestTextArea.setRows(5);
        jScrollPane1.setViewportView(requestTextArea);

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 449, Short.MAX_VALUE)
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel1Layout.createSequentialGroup()
                        .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 132, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(BPNameField, javax.swing.GroupLayout.PREFERRED_SIZE, 110, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, 75, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(clusterNameField, javax.swing.GroupLayout.DEFAULT_SIZE, 106, Short.MAX_VALUE))
                    .addComponent(getAppRequest)
                    .addComponent(jSeparator2, javax.swing.GroupLayout.DEFAULT_SIZE, 449, Short.MAX_VALUE))
                .addContainerGap())
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel3)
                    .addComponent(BPNameField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel4)
                    .addComponent(clusterNameField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(getAppRequest)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jSeparator2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 217, Short.MAX_VALUE)
                .addContainerGap())
        );

        isvTab.addTab("Add Application Request", jPanel1);

        jLabel1.setText("Import as Original");

        javax.swing.GroupLayout myIsvpDetailsPanelLayout = new javax.swing.GroupLayout(myIsvpDetailsPanel);
        myIsvpDetailsPanel.setLayout(myIsvpDetailsPanelLayout);
        myIsvpDetailsPanelLayout.setHorizontalGroup(
            myIsvpDetailsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(myIsvpDetailsPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(myIsvpDetailsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(isvTab, javax.swing.GroupLayout.DEFAULT_SIZE, 474, Short.MAX_VALUE)
                    .addComponent(jLabel1)
                    .addComponent(jSeparator1, javax.swing.GroupLayout.DEFAULT_SIZE, 474, Short.MAX_VALUE)
                    .addGroup(myIsvpDetailsPanelLayout.createSequentialGroup()
                        .addGroup(myIsvpDetailsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(isvPathLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(isvNameLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(isvUpdateNumLabel))
                        .addGap(32, 32, 32)
                        .addGroup(myIsvpDetailsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(isvUpdateNumField, javax.swing.GroupLayout.DEFAULT_SIZE, 367, Short.MAX_VALUE)
                            .addComponent(isvNameField, javax.swing.GroupLayout.DEFAULT_SIZE, 367, Short.MAX_VALUE)
                            .addComponent(isvPathField, javax.swing.GroupLayout.DEFAULT_SIZE, 367, Short.MAX_VALUE))))
                .addContainerGap())
        );
        myIsvpDetailsPanelLayout.setVerticalGroup(
            myIsvpDetailsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(myIsvpDetailsPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(myIsvpDetailsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(isvPathField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(isvPathLabel))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(myIsvpDetailsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(isvNameLabel)
                    .addComponent(isvNameField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(myIsvpDetailsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(isvUpdateNumField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(isvUpdateNumLabel))
                .addGap(33, 33, 33)
                .addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jLabel1)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(isvTab, javax.swing.GroupLayout.PREFERRED_SIZE, 330, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );

        javax.swing.GroupLayout containerPaneLayout = new javax.swing.GroupLayout(containerPane);
        containerPane.setLayout(containerPaneLayout);
        containerPaneLayout.setHorizontalGroup(
            containerPaneLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(myLanguagesPanel, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 504, Short.MAX_VALUE)
            .addGroup(containerPaneLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(containerPaneLayout.createSequentialGroup()
                    .addGap(0, 3, Short.MAX_VALUE)
                    .addComponent(myIsvpDetailsPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGap(0, 3, Short.MAX_VALUE)))
            .addGroup(containerPaneLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(containerPaneLayout.createSequentialGroup()
                    .addGap(0, 5, Short.MAX_VALUE)
                    .addComponent(myPrivilegesPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGap(0, 5, Short.MAX_VALUE)))
            .addGroup(containerPaneLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(containerPaneLayout.createSequentialGroup()
                    .addGap(0, 5, Short.MAX_VALUE)
                    .addComponent(myApplicationDetailsPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGap(0, 5, Short.MAX_VALUE)))
        );
        containerPaneLayout.setVerticalGroup(
            containerPaneLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(myLanguagesPanel, javax.swing.GroupLayout.DEFAULT_SIZE, 521, Short.MAX_VALUE)
            .addGroup(containerPaneLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(containerPaneLayout.createSequentialGroup()
                    .addGap(0, 15, Short.MAX_VALUE)
                    .addComponent(myIsvpDetailsPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGap(0, 16, Short.MAX_VALUE)))
            .addGroup(containerPaneLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(containerPaneLayout.createSequentialGroup()
                    .addGap(0, 0, Short.MAX_VALUE)
                    .addComponent(myPrivilegesPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGap(0, 0, Short.MAX_VALUE)))
            .addGroup(containerPaneLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(containerPaneLayout.createSequentialGroup()
                    .addGap(0, 15, Short.MAX_VALUE)
                    .addComponent(myApplicationDetailsPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGap(0, 16, Short.MAX_VALUE)))
        );

        javax.swing.GroupLayout positioningPanelLayout = new javax.swing.GroupLayout(positioningPanel);
        positioningPanel.setLayout(positioningPanelLayout);
        positioningPanelLayout.setHorizontalGroup(
            positioningPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(containerPane, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
        );
        positioningPanelLayout.setVerticalGroup(
            positioningPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(containerPane, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );

        CardLayout treeCards = new CardLayout();
        containerPane.setLayout(treeCards);
        treeCards.addLayoutComponent(myIsvpDetailsPanel, isvp.constants.UIConstants.ISVP_NODE_NAME);
        treeCards.addLayoutComponent(myApplicationDetailsPanel, isvp.constants.UIConstants.APPLICATION_NODE_NAME);
        treeCards.addLayoutComponent(myPrivilegesPanel, isvp.constants.UIConstants.PRIVILEGES_NODE_NAME);
        treeCards.addLayoutComponent(myLanguagesPanel, isvp.constants.UIConstants.LANGUAGES_NODE_NAME);

        jMenu1.setBackground(new java.awt.Color(236, 233, 216));
        jMenu1.setText("File");

        fileOpen.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_O, java.awt.event.InputEvent.CTRL_MASK));
        fileOpen.setText("Open                  ");
        fileOpen.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                fileOpenActionPerformed(evt);
            }
        });
        jMenu1.add(fileOpen);

        jMenuBar1.add(jMenu1);

        setJMenuBar(jMenuBar1);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(treePane, javax.swing.GroupLayout.PREFERRED_SIZE, 230, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(positioningPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                    .addComponent(positioningPanel, javax.swing.GroupLayout.Alignment.LEADING, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(treePane, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 481, Short.MAX_VALUE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void initEvents() {
        ISVPTreeSelectionEvent selectionEvent = new ISVPTreeSelectionEvent(this, componentTree);
    }
    
    private void getAppRequestActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_getAppRequestActionPerformed
        Application application = isvpObject.getApplication();
        String adminPrivilegeName = isvpObject.getAdministratorPrivilege();
        Privilege adminPrivilege = isvpObject.getPrivilege(adminPrivilegeName);
        String request = ISVPConstants.ADD_APPLICATION_REQUEST;
        request = request.replaceAll(ISVPConstants.REQUEST_APPLICATION_ID, application.getApplicationId());
        request = request.replaceAll(ISVPConstants.REQUEST_APPLICATION_DESCRIPTION, application.getApplicationDescription());
        request = request.replaceAll(ISVPConstants.REQUEST_APPLICATION_NAME, application.getApplicationName());
        request = request.replaceAll(ISVPConstants.REQUEST_BUSINESS_PARTNER_NAME, BPNameField.getText());
        request = request.replaceAll(ISVPConstants.REQUEST_CLUSTER_NAME, clusterNameField.getText());
        request = request.replaceAll(ISVPConstants.REQUEST_ISV_NAME, isvpObject.getIsvpName());
        request = request.replaceAll(ISVPConstants.REQUEST_PRIVILEGE_ID, adminPrivilege.getPrivilegeId());
        request = request.replaceFirst("<?.*?>", "");
        requestTextArea.setText(request);
    }//GEN-LAST:event_getAppRequestActionPerformed

    /**
     * Handler that handles the file open action
     * @param evt 
     */
    private void fileOpenActionPerformed(java.awt.event.ActionEvent evt) {
        //display the file chooser on click of the Open in the File menu
        int status = isvpChooser.showOpenDialog(fileOpen);
        if (status == JFileChooser.APPROVE_OPTION) {
            File selectedIsvp = isvpChooser.getSelectedFile();
                try {
                    isvpObject = ISVPFactory.getISVPImplementation(selectedIsvp);
                    componentTree.removeAll();
                    renderISVPTree();
                    showMainPanes(true);
                    selectedFilePath = selectedIsvp.getAbsolutePath();
                    fillISVPDetails();
                    componentTree.setSelectionRow(0);
                    CardLayout cards = (CardLayout)this.getPanelLayout();
                    cards.show(containerPane, UIConstants.ISVP_NODE_NAME);
                } catch (ISVPException ex) {
                    showError(ex.getMessage());
                }
        }
    }
    
    /**
     * To get the card layout associated with the containerPane
     */
    @Override
    public LayoutManager getPanelLayout() {
        return containerPane.getLayout();
    }
    
    @Override
    public Container getContainerPane() {
        return containerPane;
    }
    /**
     * This method renders the ISVP tree replacing the default tree model with
     * data required for the application 
     */
    private void renderISVPTree() {
        componentTree.setIsvpObject(isvpObject);
        TreeMap<String, ISVPJPanel> panelMap = new TreeMap<String, ISVPJPanel>();
        panelMap.put(UIConstants.ISVP_NODE_NAME, myIsvpDetailsPanel);
        panelMap.put(UIConstants.PRIVILEGES_NODE_NAME, myPrivilegesPanel);
        panelMap.put(UIConstants.APPLICATION_NODE_NAME, myApplicationDetailsPanel);
        panelMap.put(UIConstants.LANGUAGES_NODE_NAME, myLanguagesPanel);
        componentTree.renderISVPTree(panelMap);
    }
    
    @Override
   public void fillISVPDetails() {
       isvPathField.setText(selectedFilePath);
       isvNameField.setText(isvpObject.getIsvpName());
       isvUpdateNumField.setText(isvpObject.getIsvpUpdateNumber());
       fillMailFormat();
    }
    
   private void fillMailFormat() {
       Application application = isvpObject.getApplication();
       String mailContent = "Application Name - ";
       mailContent += application.getApplicationName() + "\nApplication ID - ";
       mailContent += application.getApplicationId() + "\nPrivilege ID - ";
       String adminPrivilegeName = isvpObject.getAdministratorPrivilege();
       Privilege adminPrivilege = isvpObject.getPrivilege(adminPrivilegeName);
       mailContent += adminPrivilege.getPrivilegeId() + "\nISV Name - ";
       mailContent += isvpObject.getIsvpName();
       isvOrgMail.setText(mailContent);
   }
    @Override
    public void fillApplicationDetails(Application application) {
        appDescriptionField.setText(application.getApplicationDescription());
        appFileNameField.setText(application.getApplicationFileName());
        appIdField.setText(application.getApplicationId());
        appNameField.setText(application.getApplicationName());
        languageCodeField.setText(application.getApplicationLanguageCode());
        createdDateField.setText(application.getApplicationCreatedDate());
        tenantIdField.setText(application.getTenantId());
    }
    
    @Override
    public void fillPrivilegeDetails(Privilege privilege) {
        priIdField.setText(privilege.getPrivilegeId());
        priFileNameField.setText(privilege.getPrivilegeName());
        priCordysRoleDnField.setText(privilege.getCordysRole());
        priDescriptionField.setText(privilege.getPrivilegeDescription());
        priFileNameField.setText(privilege.getPrivilegeFileName());
        priNameField.setText(privilege.getPrivilegeName());
        priMenuKeyField.setText(privilege.getMenuKey());
        Node node = privilege.getAttachmentFilter();
        fillFieldFromNode(node, priAttachFilterField);
        node = privilege.getBOAccessRights();
        fillFieldFromNode(node, priBoAccessField);
        node = privilege.getDeleteFilter();
        fillFieldFromNode(node, priDeleteFilterField);
        node = privilege.getFormPrivileges();
        fillFieldFromNode(node, priFormsField);
        node = privilege.getInsertFilter();
        fillFieldFromNode(node, priInsertFilterField);
        node = privilege.getLabelPrivileges();
        fillFieldFromNode(node, priLabelField);
        node = privilege.getMenuXML();
        fillFieldFromNode(node, priMenuXmlField);
        node = privilege.getMobilePrivileges();
        fillFieldFromNode(node, priMobileField);
        node = privilege.getPsvPrivilege();
        fillFieldFromNode(node, priPsvField);
        node = privilege.getReadFilter();
        fillFieldFromNode(node, priReadFilterField);
        node = privilege.getUpdateFilter();
        fillFieldFromNode(node, priUpdateFilterField);
    }
    
    private void fillFieldFromNode(Node node, javax.swing.JTextArea field) {
        String nodeString = XMLUtils.getXMLText(node);
        try {
            nodeString = XMLUtils.getIndentedXML(nodeString);
        } catch (SAXException ex) {            
        }
        field.setText(nodeString);
    }
    
    private void showError(String message) {
        JOptionPane.showMessageDialog(this, message, "Error", JOptionPane.ERROR_MESSAGE);
    }
    
    /**
     * To show/hide the main panes of the frame
     * @param isVisible : shows the panes when true 
     */
    private void showMainPanes(boolean isVisible) {
        treePane.setVisible(isVisible);
        containerPane.setVisible(isVisible);
    }
    
    /**
     *  Loads the main frame
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            @Override
            public void run() {
                new MainFrame();
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JTextField BPNameField;
    private javax.swing.JTextField appDescriptionField;
    private javax.swing.JLabel appDescriptionLabel;
    private javax.swing.JTextField appFileNameField;
    private javax.swing.JTextField appIdField;
    private javax.swing.JLabel appIdLabel;
    private javax.swing.JTextField appNameField;
    private javax.swing.JLabel appNameLabel;
    private javax.swing.JTextField clusterNameField;
    private isvp.ui.beans.ISVPTree componentTree;
    private javax.swing.JPanel containerPane;
    private javax.swing.JTextField createdDateField;
    private javax.swing.JLabel createdDateLabel;
    private javax.swing.JPanel fieldsPanel;
    private javax.swing.JLabel fileNameLabel;
    private javax.swing.JMenuItem fileOpen;
    private javax.swing.JButton getAppRequest;
    private javax.swing.JTextField isvNameField;
    private javax.swing.JLabel isvNameLabel;
    private javax.swing.JTextArea isvOrgMail;
    private javax.swing.JTextField isvPathField;
    private javax.swing.JLabel isvPathLabel;
    private javax.swing.JTabbedPane isvTab;
    private javax.swing.JTextField isvUpdateNumField;
    private javax.swing.JLabel isvUpdateNumLabel;
    private javax.swing.JFileChooser isvpChooser;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JMenu jMenu1;
    private javax.swing.JMenuBar jMenuBar1;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane10;
    private javax.swing.JScrollPane jScrollPane11;
    private javax.swing.JScrollPane jScrollPane12;
    private javax.swing.JScrollPane jScrollPane13;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JScrollPane jScrollPane3;
    private javax.swing.JScrollPane jScrollPane4;
    private javax.swing.JScrollPane jScrollPane5;
    private javax.swing.JScrollPane jScrollPane6;
    private javax.swing.JScrollPane jScrollPane7;
    private javax.swing.JScrollPane jScrollPane8;
    private javax.swing.JScrollPane jScrollPane9;
    private javax.swing.JSeparator jSeparator1;
    private javax.swing.JSeparator jSeparator2;
    private javax.swing.JLabel langCodeLabel;
    private javax.swing.JTextField languageCodeField;
    private javax.swing.JTextField languageCreatedByField;
    private javax.swing.JLabel languageCreatedByLabel;
    private javax.swing.JTextField languageCreatedDateField;
    private javax.swing.JLabel languageCreatedDateLabel;
    private javax.swing.JTextField languageModifiedByField;
    private javax.swing.JLabel languageModifiedByLabel;
    private javax.swing.JTextField languageModifiedDateField;
    private javax.swing.JLabel languageModifiedDateLabel;
    private javax.swing.JTextField languageNameField;
    private javax.swing.JLabel languageNameLabel;
    private javax.swing.JTextField langugaeCodeField;
    private javax.swing.JLabel langugaeCodeLabel;
    private isvp.ui.beans.ISVPJPanel myApplicationDetailsPanel;
    private isvp.ui.beans.ISVPJPanel myIsvpDetailsPanel;
    private isvp.ui.beans.ISVPJPanel myLanguagesPanel;
    private isvp.ui.beans.ISVPJPanel myPrivilegesPanel;
    private javax.swing.JPanel positioningPanel;
    private javax.swing.JTextArea priAttachFilterField;
    private javax.swing.JTextArea priBoAccessField;
    private javax.swing.JTextField priCordysRoleDnField;
    private javax.swing.JLabel priCordysRoleDnLabel;
    private javax.swing.JTextArea priDeleteFilterField;
    private javax.swing.JTextField priDescriptionField;
    private javax.swing.JLabel priDescriptionLabel;
    private javax.swing.JTextField priFileNameField;
    private javax.swing.JLabel priFileNameLabel;
    private javax.swing.JTextArea priFormsField;
    private javax.swing.JTextField priIdField;
    private javax.swing.JLabel priIdLabel;
    private javax.swing.JTextArea priInsertFilterField;
    private javax.swing.JTextArea priLabelField;
    private javax.swing.JTextField priMenuKeyField;
    private javax.swing.JLabel priMenuKeyLabel;
    private javax.swing.JTextArea priMenuXmlField;
    private javax.swing.JTextArea priMobileField;
    private javax.swing.JTextField priNameField;
    private javax.swing.JLabel priNameLabel;
    private javax.swing.JTextArea priPsvField;
    private javax.swing.JTextArea priReadFilterField;
    private javax.swing.JTabbedPane priTabContainer;
    private javax.swing.JTextArea priUpdateFilterField;
    private javax.swing.JTextArea requestTextArea;
    private javax.swing.JTextField tenantIdField;
    private javax.swing.JLabel tenantIdLabel;
    private javax.swing.JScrollPane treePane;
    // End of variables declaration//GEN-END:variables
}
